Skip to content

Add a deprecation test that runs the notebooks with the classiq API mocked - #1807

Open
classiqdor wants to merge 8 commits into
mainfrom
deprecations_test
Open

classiqdor wants to merge 8 commits into
mainfrom
deprecations_test

Conversation

@classiqdor

Copy link
Copy Markdown
Contributor

A test that runs every notebook, and the README's code blocks, with the classiq API mocked, and fails on deprecation warnings.

The test (tests/deprecations/test_deprecations.py) is one parametrized test over iterate_notebooks(), like test__community_and_functions.py, plus one test for the README. It injects a cell that installs the mock, runs the whole notebook, and fails on:

  • any deprecation warning, from any source: DeprecationWarning, PendingDeprecationWarning, FutureWarning (including ClassiqDeprecationWarning) and SyntaxWarning.
  • any error. A small skip list names the 10 notebooks the fakes can't run to their end, each with its reason.

The mock (tests/deprecations/mock_classiq_api.py) runs inside the kernel:

  • Every classiq API call returns a fake but valid result, so the notebook reaches its later calls (sample, ExecutionSession, observe, get_transpiled_circuit_metrics, export, ...). Fakes cover synthesis, sampling, state vectors, estimation, minimization, metrics, export, the legacy VQE flow, the hardware list and RB analysis.
  • A sample returns every combination of main's output values (up to 14 qubits), decoded with the SDK's own parser, so structs, arrays and fixed-point numbers look real. Filters such as calculate_state_vector(filters=...) are applied.
  • Nothing reaches the platform. A call without a fake raises MockedClassiqApiCall, and nothing authenticates.
  • The fakes can't reproduce real results, so the notebooks' assert statements are skipped, like with python -O. This is its own commit, in case we'd rather do this differently.
  • Warnings are recorded with simplefilter("always"), and reported with their notebook cell and source location.

Also:

  • tests/config_deprecations.ini, and tests/deprecations in the quick tests' norecursedirs.
  • The test step of Test-CI-deprecations.yml. The job stays off (if: false). I enabled it temporarily to dispatch full runs, and it's off again.

Results. The last full run (about 30 minutes): 173 notebooks pass, 38 fail on a real deprecation (listed in the comments), and 10 are skipped.

Known limits

  • Deprecated pydantic fields (e.g. some Preferences fields) warn only when they're read, not when they're set, so running a notebook can't catch them.
  • Code that only runs on hardware (RUN_ON_HARDWARE = False), and benchmark notebooks that reuse their saved results, never reach their execution calls.

🤖 Generated with Claude Code

@classiqdor

classiqdor commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Findings from the full run (a dispatch of this test on every notebook): 38 notebooks fail on a deprecation, and each one is either fixed by an open PR or needs an SDK fix. No third-party deprecation came up.

Warning Raised at Notebooks Fixed by
ExecutionSession.minimize is deprecated; use variational_minimize instead. classiq/applications/combinatorial_optimization/combinatorial_problem.py:258, inside CombinatorialProblem.optimize 21: electric_grid_optimization, evidence_scaling_labs, facility_location, integer_linear_programming, ising_model, learning_optimization, link_monitoring, max_clique, max_independent_set, max_induced_k_color_subgraph, max_k_vertex_cover, min_graph_coloring, minimum_dominating_set, patch_min_vertex_cover, portfolio_optimization, protein_folding, radio_access_network_positioning_antennas, set_cover, set_partition, task_scheduling_problem, traveling_salesman_problem the SDK
Accessing 'quantum_program.transpiled_circuit.depth' (.count_ops, .qasm) is deprecated notebook cells 11: ND_Laplacian_BE, advection_equation_2nd_place_submission, advection_equation_winning_submission, classiq_iQuHack_2025_final, classiq_iQuHack_2025_final_sol, classiq_iQuHack_2025_quantum_tree_sol, qaoa_demonstration, quantum_walks_via_efficient_blockencoding, select_structures_BE, stateprep_guassian_using_qsvt, resiliency_planning_AMD #1787 (open)
SyntaxWarning: invalid escape sequence notebook cells fermionic_gaussian, verify_block_encoding, qpe_for_molecules, logical_qubits_by_alice_and_bob (and fermi_hubbard_1D, which is skipped) #1797 (merged)
SyntaxWarning: invalid escape sequence '\p' benchmarking/benchmarks/examples/ghz.py:48 benchmark_ghz #1785 (merged)
Function 'modular_exp' is deprecated classiq/open_library/functions/modular_arithmetics.py:333 modular_exp_example #1784 (merged)

Not caught by running:

classiqdor and others added 8 commits November 19, 2026 17:27
…ocked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ults

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ors, and skip the notebooks the fakes can't run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shots than states, and skip adapt_qaoa

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant